import Pinyin from '@/utils/ChinesePY.js'
export function setFamilyNameFirst(fromValue, arr) {
  const fromValueList = Object.keys(fromValue)
  const b = []
  fromValueList.forEach(item => {
    if (item.includes('familyName')) {
      const a = item.split('familyName')
      if (a[1] === '' || +(a[1])) b.push(a[1])
    }
  })
  b.forEach(item => {
    if (fromValue[`familyName${item}`]) {
      arr.value.forEach(it => {
        if (it.key === `familyNameFirst${item}`) it.value = ToUppercase(fromValue[`familyName${item}`])
      })
    } else {
      arr.value.forEach(it => {
        if (it.key === `familyNameFirst${item}`) it.value = ''
      })
    }
  })
}


// 提取汉字首字母  并转换为大写
const ToUppercase = function (name) {
  const fullNameFirst = Pinyin.getWordsCode(name)
  return fullNameFirst.toUpperCase()
}